package com.uhealin;

import java.io.IOException;
import java.io.OutputStream;
import java.util.Random;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;


/**
 * 
 * @author wangbin
 * 瀹炵幇鍔熻兘锛氬埗閫犳暟鎹�
 * 
 *
 */
public class CreateData {

	public static void main(String[] args) throws IOException {
		
		if(args.length < 2){
			System.out.println("args0:fs.default.name");
			System.out.println("args1:hdfs_path");
			
			System.exit(0);
		}
		
		int len = 60000;
		int hotel = 2000;
		int LM = 1000;
		Random ran = new Random();
		int type = 0;
		String hdfs_path = args[1];
		Configuration conf = new Configuration();
		conf.set("fs.default.name", args[0]);
		FileSystem fs = FileSystem.get(conf);
		OutputStream out = fs.create(new Path(hdfs_path));
		for(int i = 0 ; i < hotel ; i++){  
			int hx = ran.nextInt(len);
			int hy = ran.nextInt(len);
			type = 0;
			StringBuilder str = new StringBuilder();
			str.append(type);
			str.append("\t");
			str.append(i * 10000);
			str.append("\t");
			str.append(hx); 
			str.append("\t");
			str.append(hy);
			str.append("\r\n");
			type = 1;
			for(int k = 0 ; k < LM ; k++){
				int lmx = ran.nextInt(len);
				int lmy = ran.nextInt(len);
				str.append(type);
				str.append("\t");
				str.append(i * 10000 + k + 1);
				str.append("\t");
				str.append(lmx); 
				str.append("\t");
				str.append(lmy);
				str.append("\r\n");
			}
			byte[] data = (str.toString()).getBytes("UTF8");
			out.write(data);
			System.out.println(i * 1000);
			
		}
		out.close();
		fs.close();
	}

}
